<!--
 * @Description: 
 * @Author: mxy
 * @Date: 2022-11-14 20:18:14
 * @LastEditors: mxy
 * @LastEditTime: 2022-11-14 20:23:42
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="./axios.js"></script>
    <script>
        axios.defaults.baseURL = 'http://www.itcbc.com:3006'
        //Promise.resolve()返回成功状态的promise对象
        Promise.resolve('成功').then(res => {
            console.log(res)
        })
        //Promise.reject()返回失败状态的promise对象
        Promise.reject('失败').catch(err => {
            console.log(err)
        })

        let p1 = axios.get('/api/province')
        let p2 = axios.get('/api/city', {
            params: {
                pname: '河南省'
            }
        })
        let p3 = axios.get('/api/county', {
            params: {
                pname: '河南省',
                cname: '新乡市'
            }
        })

        //Promise.all()返回所有promise对象的结果
        Promise.all([p1, p2, p3]).then(res => { console.log(res); })
        //Promise.race()返回先执行完毕的对象结果
        Promise.race([p1, p2, p3]).then(res => { console.log(res); })
    </script>
</body>

</html>